// Copyright (c) 2009 Alistair Jones
// This program is made available under the terms of the MIT License.
package org.hypirinha.html.output.print;

import static org.hypirinha.html.ElementFactory.*;
import org.hypirinha.html.elements.*;
import org.hypirinha.html.output.features.XmlDeclaration;
import org.hypirinha.html.output.features.Encoding;
import static org.hypirinha.html.output.print.MultilineString.lines;
import org.hypirinha.html.output.PrintAdapter;

import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class XmlDeclarationTest {

    @Test
    public void shouldIncludeXmlDeclarationIfSupplied() {
        Html content = html();

        String output = new PrintAdapter(XmlDeclaration.include).asString(content);

        assertEquals(lines(
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
                "<html></html>"), output);
    }

    @Test
    public void shouldReflectSpecifiedEncoding() {
        Html content = html();

        String output = new PrintAdapter(XmlDeclaration.include, Encoding.UTF_16).asString(content);

        assertEquals(lines(
                "<?xml version=\"1.0\" encoding=\"UTF-16\"?>",
                "<html></html>"), output);
    }

}